﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="QuShuiJHXD.aspx.cs" Inherits="Web.Pages.QuShui.DiXiaS.JiHuaGL.QuShuiJH.QuShuiJHXD"  Theme="Default"%>


<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>

 <!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script src="../../../../../JS/jquery.js"></script>   
    <script src="../../../../../JS/AddEditCancel.js"></script>
    <script src="../../../../../PageJS/wap.js"></script>
    <script type="text/javascript">
        function begincall() {
            loadpanel1.Show();
        }
        function endcall(gv) {
            loadpanel1.Hide();
            //定位添加或修改的记录
            var oid = hdCollection.Get("OperateID");
            var index = -1;
            if (oid != -1 && typeof (oid) != undefined) {
                for (var i = 0; i < gv.GetVisibleRowsOnPage() ; i++) {
                    if (gv.GetRowKey(i) == oid) {
                        index = i;
                    }
                }
                if (index != -1) {
                    gv.SetFocusedRowIndex(index);
                    gv.MakeRowVisible(index);
                    hdCollection.Set("OperateID", -1);
                }
            }
        }

        function display(op, id) {
            hdCollection.Set("ID", id);
            if (op == "edit") {
                lblOperateTip.SetText("修改");
                listCover(true, "divList");
                $("#GridViewContentTable").show();
                ASPxCallback1.PerformCallback("setinfo");
                txtQuShuiJH.Focus();
            }
            else {
                $("#GridViewContentTable").hide();
                listCover(false, "divList");
            }
        }

        function save() {
            //if (txtQuShuiJH.GetText() == "") {
            //    alert("取水计划量必须输入！");
            //    txtQuShuiJH.Focus();
            //    return;
            //}
            ASPxCallback1.PerformCallback("save");
        }

        function saveBatch() {
            ASPxCallback1.PerformCallback("saveBatch");
        }

        function ASPxCallback1Complete(rs) {
            var objs = eval('(' + rs + ')');
            var type = objs.type;
            if (type == "setinfo") {
                txtQSL.SetText(objs.QSL);
                txtQSL1.SetText(objs.QSL1);
                txtQSL2.SetText(objs.QSL2);
                txtQSL3.SetText(objs.QSL3);
                txtQSL4.SetText(objs.QSL4);
                txtQSL5.SetText(objs.QSL5);
                txtQSL6.SetText(objs.QSL6);
                txtQSL7.SetText(objs.QSL7);
                txtQSL8.SetText(objs.QSL8);
                txtQSL9.SetText(objs.QSL9);
                txtQSL10.SetText(objs.QSL10);
                txtQSL11.SetText(objs.QSL11);
                txtQSL12.SetText(objs.QSL12);

                txtQuShuiJH.SetText(objs.XDJH);
                txtQuShuiJH1.SetText(objs.XDL1);
                txtQuShuiJH2.SetText(objs.XDL2);
                txtQuShuiJH3.SetText(objs.XDL3);
                txtQuShuiJH4.SetText(objs.XDL4);
                txtQuShuiJH5.SetText(objs.XDL5);
                txtQuShuiJH6.SetText(objs.XDL6);
                txtQuShuiJH7.SetText(objs.XDL7);
                txtQuShuiJH8.SetText(objs.XDL8);
                txtQuShuiJH9.SetText(objs.XDL9);
                txtQuShuiJH10.SetText(objs.XDL10);
                txtQuShuiJH11.SetText(objs.XDL11);
                txtQuShuiJH12.SetText(objs.XDL12);
            }
            else if (type == "save") {
                if (objs.success) {
                    $("#GridViewContentTable").hide();
                    listCover(false, "divList");
                    gvList.PerformCallback();
                }
                else {
                    alert(objs.msg);
                }
            }
            else if (type == "saveBatch") {
                if (objs.success) {
                    gvList.PerformCallback();
                }
                else {
                    alert(objs.msg);
                }
            }
        }

        function toInt(v) {
            var val = parseInt(v * 100);
            if (isNaN(val)) return 0;
            else return val;
        }

        function sumSL(tp) {
            var sum = toInt(txtQuShuiJH1.GetText()) + toInt(txtQuShuiJH2.GetText())
                    + toInt(txtQuShuiJH3.GetText()) + toInt(txtQuShuiJH4.GetText())
                    + toInt(txtQuShuiJH5.GetText()) + toInt(txtQuShuiJH6.GetText())
                    + toInt(txtQuShuiJH7.GetText()) + toInt(txtQuShuiJH8.GetText())
                    + toInt(txtQuShuiJH9.GetText()) + toInt(txtQuShuiJH10.GetText())
                    + toInt(txtQuShuiJH11.GetText()) + toInt(txtQuShuiJH12.GetText());
            txtQuShuiJH.SetText((sum / 100).toFixed(2));
        }

        function print(qskbh) {
            var params = new Array();
            params.push("V_Y:" + cmbNianF1.GetText());
            params.push("V_QUSHUIKH:" + qskbh);
            params.push("V_DAYINRQ:" + txtPrintDate.GetText());
            wap.common.printjx('ZhangDanDY',
                [
                    { key: 'QUERYPARAM', value: params.join("|") },
                    { key: 'BAOBIAOID', value: "120006" },
                    { key: 'USERINFO', value: "csms" }
                ]);
        }

    </script>
    <style type="text/css">
        .FloatLeft { float: left; }
        .FloatRight { float: right; }
        .HideWork { display: none; }
    </style>
</head>
<body>
     <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div class="tabletitle1" align="center">
            取水计划下达
        </div>
         <dx:ASPxHiddenField ID="hdCollection" ClientInstanceName="hdCollection" runat="server"></dx:ASPxHiddenField>
         <dx:ASPxCallback ID="ASPxCallback1" ClientInstanceName="ASPxCallback1" runat="server" OnCallback="ASPxCallback1_Callback" ClientSideEvents-CallbackComplete="function(s,e){ASPxCallback1Complete(e.result);}"></dx:ASPxCallback>
         <dx:ASPxLoadingPanel ID="ASPxLoadingPanel1" ClientInstanceName="loadpanel1" runat="server" ContainerElementID="gvList" Modal="true" Theme="Metropolis" ShowImage="false" Text="加载中"></dx:ASPxLoadingPanel>

         <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>

                <div>
                    <table style="width: 100%; margin: auto; float: left;">
                        <tr>
                            <td align="left" style="width: 5%">年份：
                            </td>
                            <td align="left" style="width: 18%">
                                <dx:ASPxComboBox ID="cmbNianF1" runat="server" Width="60%" AutoPostBack="true" OnSelectedIndexChanged="btnQuery_Click">
                                </dx:ASPxComboBox>
                            </td>
                            <td>
                                <dx:ASPxRadioButtonList ID="rblWorktype" runat="server" RepeatColumns="3" SelectedIndex="0" Width="300px" AutoPostBack="True" OnSelectedIndexChanged="btnQuery_Click">
                                    <Items>
                                        <dx:ListEditItem Selected="True" Text="未下达" Value="0" />
                                        <dx:ListEditItem Text="已下达" Value="1" />
                                        <dx:ListEditItem Text="全部" Value="2" />
                                    </Items>
                                </dx:ASPxRadioButtonList>
                            </td>
                            <td>
                                <dx:ASPxLabel runat="server" ID="lbcount" ForeColor="Blue"></dx:ASPxLabel>
                            </td>
                            <td style="float:right; text-align: right">
                                    <dx:ASPxButton ID="btnBatch" ClientInstanceName="btnBatch" runat="server" Text="批量下达" AutoPostBack="false" UseSubmitBehavior="false" ClientSideEvents-Click="function(s,e){saveBatch();}" CssClass="FloatRight">
                                    </dx:ASPxButton>
                            </td>
                            <td style="width: 150px; text-align: right" >&nbsp;&nbsp;&nbsp;打印日期：</td>
                            <td style="width: 100px"><dx:ASPxDateEdit runat="server" ID="txtPrintDate" Width="100"></dx:ASPxDateEdit></td>
                             <td style="float:right; text-align: right">
                                <dx:ASPxButton ID="btnPrint" runat="server" Text="批量打印">
                                    <ClientSideEvents Click="function(s,e){print(0);}"/>
                                </dx:ASPxButton>
                            </td>
                           
                        </tr>
                    </table>

                    <div id="divList">
                        <dx:ASPxGridView ID="gvList" ClientInstanceName="gvList" runat="server" AutoGenerateColumns="False" KeyFieldName="S_QUSHUIKBH" Theme="Aqua1" 
                            Settings-ShowVerticalScrollBar="true" Width="100%" OnCustomCallback="gvList_CustomCallback" OnCustomColumnDisplayText="gvList_CustomColumnDisplayText">
                            <Columns>
                                <dx:GridViewDataTextColumn Caption="序号" UnboundType="String" VisibleIndex="0" Width="40px"></dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_QUSHUIKBH" Caption="取水口号" Width="70px">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_QUSHUIKM" Caption="取水口名" Width="170px">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_YONGHUH" Caption="用户号" Width="70px">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_YONGHUM" Caption="用户名" Width="170px">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="CZSPL" Caption="我处上报量（万立方米）" Width="160px">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="XDL" Caption="下达计划量（万立方米）" Width="160px">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn Width="35px" FixedStyle="Left">
                                    <DataItemTemplate>
                                        <a href="#" onclick="display('edit','<%#Eval("S_QUSHUIKBH")%>')"
                                            class="<%#Convert.ToInt32(Eval("I_WORKT")) == 0 ? "" : "HideWork"%>">下达</a>
                                        <a href="#" onclick="print('<%#Eval("S_QUSHUIKBH")%>')"
                                            class="<%#Convert.ToInt32(Eval("I_WORKT")) == 1 ? "" : "HideWork"%>">打印</a>
                                    </DataItemTemplate>
                                </dx:GridViewDataTextColumn>
                            </Columns>
                            <Settings  VerticalScrollBarMode="Visible" VerticalScrollableHeight="200" HorizontalScrollBarMode="Auto"/>
                            <SettingsPager Mode="EndlessPaging" PageSize="100"  FirstPageButton-Visible="true" />
                            <SettingsBehavior ProcessFocusedRowChangedOnServer="false" ColumnResizeMode="Control"  />
                            <ClientSideEvents Init="function(s,e){AdjustSize(200,gvList);}" BeginCallback="function(s,e){begincall();}" EndCallback="function(s,e){endcall(s);}" />
                        </dx:ASPxGridView>
                    </div>
                </div>
                    <div style="height: 3px;"></div>

                    <div id="GridViewContentTable" style="display: none">
                        <div class="tabletitle1" align="center">
                            <dx:ASPxLabel ID="lblOperateTip" runat="server" ClientInstanceName="lblOperateTip" Text="下达"></dx:ASPxLabel>
                        </div>
                        <table style="width: 100%;">
                            <tr>
                                <td>
                                    <table style="width: 100%;">
                                        <tr>
                                            <td></td>
                                            <td style="text-align: center">一月</td>
                                            <td style="text-align: center">二月</td>
                                            <td style="text-align: center">三月</td>
                                            <td style="text-align: center">四月</td>
                                            <td style="text-align: center">五月</td>
                                            <td style="text-align: center">六月</td>
                                            <td style="text-align: center">七月</td>
                                            <td style="text-align: center">八月</td>
                                            <td style="text-align: center">九月</td>
                                            <td style="text-align: center">十月</td>
                                            <td style="text-align: center">十一月</td>
                                            <td style="text-align: center">十二月</td>
                                            <td style="text-align: center">全年</td>
                                        </tr>
                                        <tr>
                                            <td style="text-align: right; width: 100px">我处上报量：</td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQSL1" ClientInstanceName="txtQSL1" runat="server" CssClass="FloatLeft" Width="72px" ReadOnly="True"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQSL2" ClientInstanceName="txtQSL2" runat="server" CssClass="FloatLeft" Width="72px" ReadOnly="True"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQSL3" ClientInstanceName="txtQSL3" runat="server" CssClass="FloatLeft" Width="72px" ReadOnly="True"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQSL4" ClientInstanceName="txtQSL4" runat="server" CssClass="FloatLeft" Width="72px" ReadOnly="True"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQSL5" ClientInstanceName="txtQSL5" runat="server" CssClass="FloatLeft" Width="72px"  ReadOnly="True"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQSL6" ClientInstanceName="txtQSL6" runat="server" CssClass="FloatLeft" Width="72px"  ReadOnly="True"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQSL7" ClientInstanceName="txtQSL7" runat="server" CssClass="FloatLeft" Width="72px"  ReadOnly="True"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQSL8" ClientInstanceName="txtQSL8" runat="server" CssClass="FloatLeft" Width="72px"  ReadOnly="True"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQSL9" ClientInstanceName="txtQSL9" runat="server" CssClass="FloatLeft" Width="72px"  ReadOnly="True"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQSL10" ClientInstanceName="txtQSL10" runat="server" CssClass="FloatLeft" Width="72px"  ReadOnly="True"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQSL11" ClientInstanceName="txtQSL11" runat="server" CssClass="FloatLeft" Width="72px"  ReadOnly="True"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQSL12" ClientInstanceName="txtQSL12" runat="server" CssClass="FloatLeft" Width="72px"  ReadOnly="True"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQSL" ClientInstanceName="txtQSL" runat="server" CssClass="FloatLeft" Width="80px"  ReadOnly="True"></dx:ASPxTextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="text-align: right; width: 100px">下达计划量：</td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQuShuiJH1" ClientInstanceName="txtQuShuiJH1" runat="server" CssClass="FloatLeft" Width="72px" ClientSideEvents-LostFocus="function(s,e){sumSL(1);}"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQuShuiJH2" ClientInstanceName="txtQuShuiJH2" runat="server" CssClass="FloatLeft" Width="72px" ClientSideEvents-LostFocus="function(s,e){sumSL(1);}"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQuShuiJH3" ClientInstanceName="txtQuShuiJH3" runat="server" CssClass="FloatLeft" Width="72px" ClientSideEvents-LostFocus="function(s,e){sumSL(1);}"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQuShuiJH4" ClientInstanceName="txtQuShuiJH4" runat="server" CssClass="FloatLeft" Width="72px" ClientSideEvents-LostFocus="function(s,e){sumSL(1);}"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQuShuiJH5" ClientInstanceName="txtQuShuiJH5" runat="server" CssClass="FloatLeft" Width="72px" ClientSideEvents-LostFocus="function(s,e){sumSL(1);}"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQuShuiJH6" ClientInstanceName="txtQuShuiJH6" runat="server" CssClass="FloatLeft" Width="72px" ClientSideEvents-LostFocus="function(s,e){sumSL(1);}"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQuShuiJH7" ClientInstanceName="txtQuShuiJH7" runat="server" CssClass="FloatLeft" Width="72px" ClientSideEvents-LostFocus="function(s,e){sumSL(1);}"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQuShuiJH8" ClientInstanceName="txtQuShuiJH8" runat="server" CssClass="FloatLeft" Width="72px" ClientSideEvents-LostFocus="function(s,e){sumSL(1);}"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQuShuiJH9" ClientInstanceName="txtQuShuiJH9" runat="server" CssClass="FloatLeft" Width="72px" ClientSideEvents-LostFocus="function(s,e){sumSL(1);}"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQuShuiJH10" ClientInstanceName="txtQuShuiJH10" runat="server" CssClass="FloatLeft" Width="72px" ClientSideEvents-LostFocus="function(s,e){sumSL(1);}"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQuShuiJH11" ClientInstanceName="txtQuShuiJH11" runat="server" CssClass="FloatLeft" Width="72px" ClientSideEvents-LostFocus="function(s,e){sumSL(1);}"></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQuShuiJH12" ClientInstanceName="txtQuShuiJH12" runat="server" CssClass="FloatLeft" Width="72px" ClientSideEvents-LostFocus="function(s,e){sumSL(1);}" ></dx:ASPxTextBox>
                                            </td>
                                            <td align="left">
                                                <dx:ASPxTextBox ID="txtQuShuiJH" ClientInstanceName="txtQuShuiJH" runat="server" CssClass="FloatLeft" Width="80px"  ReadOnly="True" ClientSideEvents-GotFocus="function(s,e){sumSL(1);}"></dx:ASPxTextBox>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>

                        </table>

                        <table style="width: 100%">
                            <tr>
                                <td style="text-align: right;">
                                </td>
                            </tr>
                        </table>

                        <table style="width: 100%">
                            <tr>
                                <td style="text-align: right;">
                                    <hr />
                                    <dx:ASPxButton ID="btnSave" ClientInstanceName="btnSave" runat="server" Text="提交" AutoPostBack="false" UseSubmitBehavior="false" ClientSideEvents-Click="function(s,e){save();}">
                                    </dx:ASPxButton>
                                    <dx:ASPxButton ID="btnCancel" runat="server" Text="放弃" AutoPostBack="false" ClientSideEvents-Click="function(s,e){display('init',-1);}" UseSubmitBehavior="false">
                                    </dx:ASPxButton>
                                </td>
                            </tr>
                        </table>
                    </div>

               
            </ContentTemplate>
        </asp:UpdatePanel>
        <dx:ASPxButton ID="btnQuery" runat="server" Text="查询" ClientInstanceName="btnQuery" ClientVisible="False" OnClick="btnQuery_Click"></dx:ASPxButton>

    </form> 
</body>
</html> 